package com.practice.dataStructure.array;

import java.util.Arrays;
import java.util.Collections;

import static java.util.Collections.reverse;

public class JavaArrayTest {
    public static void main(String[] args) {
        int[] arr = {1, 2, 3, 4, 5};
        System.out.println("Array length: " + arr.length);
        System.out.println("Array elements:");
        for (int j : arr) {
            System.out.println(j);
        }
        // 数组的复制
        int[] arrCopy = Arrays.copyOf(arr, arr.length);
        System.out.println("Copied array elements:");
        for (int j : arrCopy) {
            System.out.println(j);
        }
        // 对数组进行反转
        reverse(Collections.singletonList(arr));
        // 数组的排序
        Arrays.sort(arr);
        System.out.println("Sorted array elements:");
        for (int j : arr) {
            System.out.println(j);
        }
    }
}
